﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>双益机械信息化管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" type="image/ico" href="~/Content/themes/icon/user_home.png" />
    <link href="~/Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Content/js/common.js"></script>
    <script src="~/Content/js/init.js" type="text/javascript"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <!--处理仪表盘-->
    
    <script type="text/javascript"> 
//导出视图数据
 exportDgData = function (dg_type) { 
     var dg_type, removefinished, department, schedule, classifyOper;
     switch (dg_type) {
         case "week_oper_time":
             removefinished = weekremovefinished;
             adjustCycle = weekadjust;
             cycle = "week";
             classifyOper = true;
             break;
         case "week_all_time":
             removefinished = week_all_removefinished;
             adjustCycle = week_all_adjust;
             classifyOper = false;
             cycle = "week";
             break;
         case "month_oper_time":
             removefinished = monthOperRemoveFinished;
             adjustCycle = monthOperAdjustnum;
             classifyOper = true;
             cycle = "month";
             break;
         case "month_all_time":
             removefinished = monthremovefinished;
             adjustCycle = monthadjust;
             classifyOper = false;
             cycle = "month";
             break;

         default:

     } 
      schedule= $('#schedule').val(),//排程方式
      department= $('#Department').val()  

      var url = "/Home/ExportExcel?r=" + Math.random();
      var data = {
                "dg_type": dg_type,
                   "cycle":cycle,
                   "removefinished": removefinished,
                 "adjust":adjustCycle,
                  "department":department,
                  "schedule":schedule,
                  "classifyOper":classifyOper,
      };
      download(url, data, 'post'); 
  }



        function formatProgress(value) {
            if (value) {
                var s = '<div style="width:100%;border:1px solid #ccc">' +
                        '<div style="width:' + value + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
                '</div>';
                return s;
            } else {
                return '';
            }
        }
        //$(function () {
            //$('.datagrid-cell').css('font-size', '18px'); //更改的是datagrid中的数据
            //$('.datagrid-header .datagrid-cell span ').css('font-size', '20px');// datagrid中的列名称
            //$('.panel-title ').css('font-size', '20px'); //标题
            //$('.datagrid-pager').css('display', 'none');// 分页工具栏
        //})
        //datagrid字体增大处理函数
        function largefont(value, row, index) {
            return '<span style="font-size: 14px;">' + value + '</span>';
        }
        //周列显示样式处理函数
        function valuedisplay(value, row, index) {
            a = parseFloat(value).toFixed(1);
            p = value * 100 / (row.DayTime * 6) > 100 ? 100 : value * 100 / (row.DayTime * 6);
            if (value > row.AlertValue * row.DayTime * 6 / 100) {
                return '<div style="width:' + p + '%;height:20px;  line-height: 22px;  position:relative;background:red; "> <span style="text-align:right;  font-size: 14px; width:75px; position:absolute; ">' + a + '</span></div>';
            } else {
                return '<div style="width:' + p + '%;height:20px; line-height: 22px;   position:relative;background:green; "> <span style="text-align:right; font-size: 14px; width:75px; position:absolute; ">' + a + '</span></div>';
            }
        }
        //月视图列显示样式处理函数
        function monthvaluedisplay(value, row, index) {
            a = parseFloat(value).toFixed(1);
            p = value * 100 / (row.DayTime * 25) > 100 ? 100 : value * 100 / (row.DayTime * 25);
            if (value > row.AlertValue * row.DayTime * 25 / 100) {
                return '<div style="width:' + p + '%;height:20px;  line-height: 22px;  position:relative;background:red; "> <span style="text-align:right; width:75px; font-size: 14px; position:absolute; ">' + a + '</span></div>';
            } else {
                return '<div style="width:' + p + '%;height:20px; line-height: 22px; position:relative;background:green; "> <span style="text-align:right; width:75px; font-size: 14px; position:absolute; ">' + a + '</span></div>';
            }
        }

       
        </script>

   
    <script>        //月产能预警
        var monthadjust = 0;//定义距离本月前后n月的值；
        var monthremovefinished = true;//月表移除已完成订单 
        //预定义month列格式
        var monthColums = [
                 { field: 'OperGroupID', title: 'Code', width: 80, hidden: true },
                   {
                       field: 'OperGroupName', title: '工艺', width: 50, formatter: function (value, row, index) { return largefont(value, row, index); }
                   },
                    {
                        field: 'AlertValue', title: '预警%', width: 30
                    },
                     {
                         field: 'DayTime', title: '月能力', width: 40,
                         formatter: function (value, row, index) { return value * 25; }
                     },
                         {
                             field: '1', title: '1', width: 80,
                             formatter: function (value, row, index) {
                                 return monthvaluedisplay(value, row, index);
                             }
                         },
                      {
                          field: '2', title: '2', width: 80,
                          formatter: function (value, row, index) {
                              return monthvaluedisplay(value, row, index);
                          }
                      },
                      {
                          field: '3', title: '3', width: 80,
                          formatter: function (value, row, index) {
                              return monthvaluedisplay(value, row, index);
                          }
                      },
                    {
                        field: '4', title: '4', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    },
                    {
                        field: '5', title: '5', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    }, {
                        field: '6', title: '6', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    }
        ];
        function monthdatagrid(_monthadjust, refresh) {
            if (!refresh) { refresh = false; }
            $.ajax({     //请求当前数据的列名
                url: "/Home/GetCapacityAlert?r=" + Math.random(),
                type: "post",
                data: { "key": "columns", adjustNum: _monthadjust, "cycle": "month" },//classifyOper:false,不分工艺，工时合并到一起；
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    //动态更新Colums
                    for (var i = 4; i < 10; i++) {
                        monthColums[i].title = data.columns[i - 1].title;
                        monthColums[i].field = data.columns[i - 1].field;
                    };
                    //获取数据
                    $("#month_all_time_dg").datagrid({
                        url: "/Home/GetCapacityAlert?r=" + Math.random(),
                        queryParams: {
                            key: 'datarows',
                            adjustNum: _monthadjust,
                            cycle: "month",
                            refresh: refresh,
                            removefinished: monthremovefinished,
                            classifyOper: false,
                            schedule: $('#schedule').val(),//排程方式
                            department: $('#Department').val()  
                        },
                        striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                        fitColumns: true, fit: true,//自适应
                        //idField: '',
                        //sortName: '',
                        //sortOrder: 'desc',
                        pageList: [20, 40, 60, 80, 100],
                        //frozenColumns: [],
                        columns: [monthColums],
                        //禁止行选中
                        onClickRow: function () {
                            $('#month_all_time_dg').datagrid('clearSelections');
                        },
                        //onLoadSuccess: function () {

                        //},
                        toolbar: [{
                            text: '上一月',
                            iconCls: 'icon-arrow_left',
                            handler: function () {
                                monthadjust--;
                                monthdatagrid(monthadjust);
                            }
                        }, {
                            text: '下一月',
                            iconCls: 'icon-arrow_right',
                            handler: function () {
                                monthadjust++;
                                monthdatagrid(monthadjust);
                            }
                        }, {
                            text: '本月',
                            iconCls: 'icon-arrow_undo',
                            handler: function () {
                                monthadjust=0;
                                monthdatagrid(monthadjust);
                            }
                        }, {
                            text: '刷新',
                            iconCls: 'icon-arrow_refresh',
                            handler: function () {
                                 monthdatagrid(monthadjust,true);
                            }
                        },
                         {
                            id: 'sbmonth'
                        }, '-',
                         {
                            text: '导出',
                            iconCls: 'icon-page_excel',
                            handler: function () { exportDgData("month_all_time"); }
                        },


                        ],
                        onLoadSuccess: function (data) {
                            $('#sbmonth').switchbutton({
                                checked: monthremovefinished,
                                onText: '是',
                                offText: '否',
                                handleText: '过滤已完成',
                                width:120,
                                handleWidth:80,
                                onChange: function (checked) { 
                                    monthremovefinished = checked;
                                    monthdatagrid(monthadjust);
                                 }
                            });
                        }
                    });

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })
        }
        </script>
    <script>
         //周产能预警--所有类型
        var week_all_adjust = 0;//定义距离本周前后n周的值；
        var week_all_removefinished = true;//周表移除已完成订单 
        //预定义week列格式
        var week_all_Colums = [
                { field: 'OperGroupID', title: 'Code', width: 80, hidden: true },
                  {
                      field: 'OperGroupName', title: '工艺', width: 50,
                      formatter: function (value, row, index) { return largefont(value, row, index); }
                  },
                   { field: 'AlertValue', title: '预警%', width: 30 },
                    {
                        field: 'DayTime', title: '周能力', width: 40,
                        formatter: function (value, row, index) { return value * 6; }
                    },
                        {
                            field: '1', title: '1', width: 80,
                            formatter: function (value, row, index) {
                                return valuedisplay(value, row, index);
                            }
                        },
                     {
                         field: '2', title: '2', width: 80,
                         formatter: function (value, row, index) {
                             // return parseFloat(value).toFixed(1);
                             return valuedisplay(value, row, index);
                         }
                     },
                     {
                         field: '3', title: '3', width: 80,
                         formatter: function (value, row, index) {
                             return valuedisplay(value, row, index);
                         }
                     },
                   {
                       field: '4', title: '4', width: 80,
                       formatter: function (value, row, index) {
                           return valuedisplay(value, row, index);
                       }
                   },
                   {
                       field: '5', title: '5', width: 80,
                       formatter: function (value, row, index) {
                           return valuedisplay(value, row, index);
                       }
                   },
                     {
                         field: '6', title: '6', width: 80,
                         formatter: function (value, row, index) {

                             return valuedisplay(value, row, index);
                         }
                     }
        ];
    function week_all_datagrid(_week_all_adjust, refresh) {
        if (!refresh) { refresh = false; }
        $.ajax({     //请求当前数据的列名
            url: "/Home/GetCapacityAlert?r=" + Math.random(),
            type: "post",
            data: { adjustNum: _week_all_adjust, "key": "columns", "cycle": "week" },
            dataType: "json",
            timeout: 5000,
            success: function (data) {
                //if (data.success) {
                //动态更新Colums
                for (var i = 4; i < 10; i++) {
                    week_all_Colums[i].title = data.columns[i - 1].title;
                    week_all_Colums[i].field = data.columns[i - 1].field;
                };

                $("#week_all_time_dg").datagrid({
                    url: "/Home/GetCapacityAlert?r=" + Math.random(),
                    queryParams: {
                        key: 'datarows',
                        cycle: "week",
                        adjustNum: _week_all_adjust,
                        removefinished: week_all_removefinished,
                        refresh: refresh,
                        classifyOper: false,
                        schedule: $('#schedule').val(),//排程方式
                        department: $('#Department').val()
                    },
                    striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                    fitColumns: true, fit: true,//自适应
                    pageList: [20, 40, 60, 80, 100],
                    //frozenColumns: [],
                    columns: [week_all_Colums],
                    //禁止行选中
                    onClickRow: function () {
                        $('#week_all_time_dg').datagrid('clearSelections');
                    },
                    toolbar: [{
                        text: '上一周',
                        iconCls: 'icon-arrow_left',
                        handler: function () {
                            week_all_adjust--;
                            week_all_datagrid(week_all_adjust);
                        }
                    }, {
                        text: '下一周',
                        iconCls: 'icon-arrow_right',
                        handler: function () {
                            week_all_adjust++;
                            week_all_datagrid(week_all_adjust);
                        }
                    }, {
                        text: '本周',
                        iconCls: 'icon-arrow_undo',
                        handler: function () {
                            week_all_adjust=0;
                            week_all_datagrid(week_all_adjust);
                        }
                    }, {
                        text: '刷新',
                        iconCls: 'icon-arrow_refresh',
                        handler: function () {
                            week_all_datagrid(week_all_adjust,true);
                        }

                    }, '-', { text: '过滤已完成订单:' }, {
                        id: 'sbweek_all'
                    }, '-',
                     {
                         text: '导出',
                         iconCls: 'icon-page_excel',
                         handler: function () { exportDgData("week_all_time"); }
                     },
                    ],
                    onLoadSuccess: function (data) {
                        $('#sbweek_all').switchbutton({
                            checked: week_all_removefinished,
                            onText: '是',
                            offText: '否',
                            onChange: function (checked) {
                                week_all_removefinished = checked;
                                week_all_datagrid(week_all_adjust);
                            }

                        });
                    }
                });

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus == "timeout") {
                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                }
                else {
                    $.show_alert("错误", textStatus + "：" + errorThrown);
                }
            }
        })
    }

    </script>
  <script>
      // 月工序工时预警！！
      var monthOperAdjustnum = 0;//定义距离本月前后n月的值；
      var monthOperRemoveFinished = true;//月表移除已完成订单
      //预定义月工序工时列格式
      var monthOperColums = [
                 { field: 'OperGroupID', title: 'Code', width: 80, hidden: true },
                   {
                       field: 'OperGroupName', title: '工艺', width: 50,
                       formatter: function (value, row, index) { return largefont(value, row, index); }
                   },
                    { field: 'AlertValue', title: '预警%', width: 30 },
                     {
                         field: 'DayTime', title: '月能力', width: 40,
                         formatter: function (value, row, index) { return value * 25; }
                     },
                         {
                             field: '1', title: '1', width: 80,
                             formatter: function (value, row, index) {
                                 return monthvaluedisplay(value, row, index);
                             }
                         },
                      {
                          field: '2', title: '2', width: 80,
                          formatter: function (value, row, index) {
                              return monthvaluedisplay(value, row, index);
                          }
                      },
                      {
                          field: '3', title: '3', width: 80,
                          formatter: function (value, row, index) {
                              return monthvaluedisplay(value, row, index);
                          }
                      },
                    {
                        field: '4', title: '4', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    },
                    {
                        field: '5', title: '5', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    },
                    {
                        field: '6', title: '6', width: 80,
                        formatter: function (value, row, index) {
                            return monthvaluedisplay(value, row, index);
                        }
                    }
      ];

    //月工序产能预警-分工艺
     function monthoperdatagrid(_monthOperAdjustnum, refresh) {
        if (!refresh) { refresh = false; }
        $.ajax({     //请求当前数据的列名
            url: "/Home/GetCapacityAlert?r=" + Math.random(),
            type: "post",
            data: { "key": "columns", "adjustNum": _monthOperAdjustnum, "cycle": "month" },
            dataType: "json",
            timeout: 5000,
            success: function (data) {
                //if (data.success) {
                //动态更新Colums
                for (var i = 4; i < 10; i++) {
                    monthOperColums[i].title = data.columns[i - 1].title;
                    monthOperColums[i].field = data.columns[i - 1].field;
                };

                $("#month_oper_time_dg").datagrid({
                    url: "/Home/GetCapacityAlert?r=" + Math.random(),
                    queryParams: {
                        key: 'datarows',
                        "cycle": "month",
                        adjustNum: _monthOperAdjustnum,
                        refresh: refresh,
                        removefinished: monthOperRemoveFinished,
                        classifyOper: true,
                        schedule: $('#schedule').val(),//排程方式
                        department: $('#Department').val()
                    },
                    striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                    fitColumns: true, fit: true,//自适应
                    pageList: [20, 40, 60, 80, 100],
                    //frozenColumns: [],
                    columns: [monthOperColums],
                    //禁止行选中
                    onClickRow: function () {
                        $('#month_oper_time_dg').datagrid('clearSelections');
                    },
                    toolbar: [{
                        text: '上一月',
                        iconCls: 'icon-arrow_left',
                        handler: function () {
                            monthOperAdjustnum--;
                            monthoperdatagrid(monthOperAdjustnum);
                        }
                    }, {
                        text: '下一月',
                        iconCls: 'icon-arrow_right',
                        handler: function () {
                            monthOperAdjustnum++;
                            monthoperdatagrid(monthOperAdjustnum);
                        }
                    }, {
                        text: '本月',
                        iconCls: 'icon-arrow_undo',
                        handler: function () {
                            monthOperAdjustnum=0;
                            monthoperdatagrid(monthOperAdjustnum);
                        }
                    }, {
                        text: '刷新',
                        iconCls: 'icon-arrow_refresh',
                        handler: function () {
                            monthoperdatagrid(monthOperAdjustnum, true);
                        }
                    }, '-', { text: '过滤已完成订单:' }, {
                        id: 'sbweek2'
                    }, '-',
                     {
                         text: '导出',
                         iconCls: 'icon-page_excel',
                         handler: function () { exportDgData("month_oper_time"); }
                     },
                    ],
                    onLoadSuccess: function (data) {
                        $('#sbweek2').switchbutton({
                            checked: monthOperRemoveFinished,
                            onText: '是',
                            offText: '否',
                            onChange: function (checked) {
                                monthOperRemoveFinished = checked;
                                monthoperdatagrid(monthOperAdjustnum);
                            }
                            //,
                            // dp:$('#Department').val()
                        });
                    }
                });

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus == "timeout") {
                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                }
                else {
                    $.show_alert("错误", textStatus + "：" + errorThrown);
                }
            }
        })
    }

    </script>

    <script>
        var weekadjust = 0;//定义距离本周前后n周的值；
        var weekremovefinished = true;//周表移除已完成订单
        //预定义week列格式
        var weekColums = [
                 { field: 'OperGroupID', title: 'Code', width: 80, hidden: true },
                   {
                       field: 'OperGroupName', title: '工艺', width: 50,
                       formatter: function (value, row, index) { return largefont(value, row, index); }
                   },
                    { field: 'AlertValue', title: '预警%', width: 30 },
                     {
                         field: 'DayTime', title: '周能力', width: 40,
                         formatter: function (value, row, index) { return value * 6; }
                     },
                         {
                             field: '1', title: '1', width: 80,
                             formatter: function (value, row, index) {
                                 return valuedisplay(value, row, index);
                             }
                         },
                      {
                          field: '2', title: '2', width: 80,
                          formatter: function (value, row, index) {
                              // return parseFloat(value).toFixed(1);
                              return valuedisplay(value, row, index);
                          }
                      },
                      {
                          field: '3', title: '3', width: 80,
                          formatter: function (value, row, index) {
                              return valuedisplay(value, row, index);
                          }
                      },
                    {
                        field: '4', title: '4', width: 80,
                        formatter: function (value, row, index) {
                            return valuedisplay(value, row, index);
                        }
                    },
                    {
                        field: '5', title: '5', width: 80,
                        formatter: function (value, row, index) {
                            return valuedisplay(value, row, index);
                        }
                    },
                      {
                          field: '6', title: '6', width: 80,
                          formatter: function (value, row, index) {

                              return valuedisplay(value, row, index);
                          }
                      }
        ];
    
      //周产能预警--分工艺
        function weekdatagrid(_weekadjust, refresh) {
            if (!refresh) { refresh = false; }
            $.ajax({     //请求当前数据的列名
                url: "/Home/GetCapacityAlert?r=" + Math.random(),
                type: "post",
                data: { "key": "columns", "adjustNum": _weekadjust, "cycle": "week" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    for (var i = 4; i < 10; i++) {
                        weekColums[i].title = data.columns[i - 1].title;
                        weekColums[i].field = data.columns[i - 1].field;
                    };

                    $("#week_oper_time_dg").datagrid({
                        url: "/Home/GetCapacityAlert?r=" + Math.random(),
                        queryParams: {
                            key: 'datarows',
                            adjustNum: _weekadjust,
                            "cycle": "week",
                            refresh: refresh,
                            removefinished: weekremovefinished,
                            classifyOper: true,
                            schedule: $('#schedule').val(),//排程方式
                            department: $('#Department').val()
                        },
                        striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                        fitColumns: true, fit: true,//自适应

                        pageList: [20, 40, 60, 80, 100],
                        //frozenColumns: [],
                        columns: [weekColums],
                        //禁止行选中
                        onClickRow: function () {
                            $('#week_oper_time_dg').datagrid('clearSelections');
                        },
                        toolbar: [{
                            text: '上一周',
                            iconCls: 'icon-arrow_left',
                            handler: function () {
                                weekadjust--;
                                weekdatagrid(weekadjust);
                            }
                        }, {
                            text: '下一周',
                            iconCls: 'icon-arrow_right',
                            handler: function () {
                                weekadjust++;
                                weekdatagrid(weekadjust);
                            }
                        }, {
                            text: '本周',
                            iconCls: 'icon-arrow_undo',
                            handler: function () {
                                weekadjust=0;
                                weekdatagrid(weekadjust);
                            }
                        }, {
                            text: '刷新',
                            iconCls: 'icon-arrow_refresh',
                            handler: function () {
                                weekdatagrid(weekadjust,true
                                );
                            }
                        }, '-', { text: '过滤已完成订单:' }, {
                            id: 'sbweek'
                        }, '-',
                         {
                             text: '导出',
                             iconCls: 'icon-page_excel',
                             handler: function () { exportDgData("week_oper_time"); }
                         },
                        ],
                        onLoadSuccess: function (data) {
                            $('#sbweek').switchbutton({
                                checked: weekremovefinished,
                                onText: '是',
                                offText: '否',
                                onChange: function (checked) {
                                    weekremovefinished = checked;
                                    weekdatagrid(weekadjust);
                                }
                                //,
                                //dep: $('#Department').val()
                            });
                        }
                    });
 
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })
        }
      </script>

    <script>
      //月工序（预估）产能预警，20190717
        var monthOperEstAdjustnum = 0; //预定义月工序预估产能预警月调整周期
        //预定义月工序预估产能预警列格式
        var monthOperEstColums = [
                  { field: 'OperGroupID', title: 'Code', width: 80, hidden: true },
                    {
                        field: 'OperGroupName', title: '工艺', width: 50,
                        formatter: function (value, row, index) { return largefont(value, row, index); }
                    },
                     { field: 'AlertValue', title: '预警%', width: 30 },
                      {
                          field: 'DayTime', title: '月能力', width: 40,
                          formatter: function (value, row, index) { return value * 25; }
                      },
                          {
                              field: '1', title: '1', width: 80,
                              formatter: function (value, row, index) {
                                  return monthvaluedisplay(value, row, index);
                              }
                          },
                       {
                           field: '2', title: '2', width: 80,
                           formatter: function (value, row, index) {
                               // return parseFloat(value).toFixed(1);
                               return monthvaluedisplay(value, row, index);
                           }
                       },
                       {
                           field: '3', title: '3', width: 80,
                           formatter: function (value, row, index) {
                               return monthvaluedisplay(value, row, index);
                           }
                       },
                     {
                         field: '4', title: '4', width: 80,
                         formatter: function (value, row, index) {
                             return monthvaluedisplay(value, row, index);
                         }
                     },
                     {
                         field: '5', title: '5', width: 80,
                         formatter: function (value, row, index) {
                             return monthvaluedisplay(value, row, index);
                         }
                     },
                     {
                         field: '6', title: '6', width: 80,
                         formatter: function (value, row, index) {
                             return monthvaluedisplay(value, row, index);
                         }
                     }
        ]; 

        function monthOperEstDatagrid(_monthOperEstAdjustnum, refresh) {
            if (!refresh) { refresh = false; }
            $.ajax({     //请求当前数据的列名
                url: "/Home/GetCapacityAlert?r=" + Math.random(),
                type: "post",
                data: { "key": "columns", "adjustNum": _monthOperEstAdjustnum, "cycle": "month" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    //if (data.success) {
                    //动态更新Colums
                    for (var i = 4; i < 10; i++) {
                        monthOperEstColums[i].title = data.columns[i - 1].title;
                        monthOperEstColums[i].field = data.columns[i - 1].field;
                    };

                    $("#month_oper_est_time_dg").datagrid({
                        url: "/Home/GetCapacityAlert?r=" + Math.random(),
                        queryParams: {
                            key: 'datarows',
                            "cycle": "month",
                            dataType:"monthOperEst",
                            adjustNum: _monthOperEstAdjustnum,
                            refresh: refresh,
                            removefinished: monthOperRemoveFinished,
                            classifyOper: true,
                            schedule: $('#schedule').val(),//排程方式
                            department: $('#Department').val()
                        },
                        striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                        fitColumns: true, fit: true,//自适应
                        pageList: [20, 40, 60, 80, 100],
                        //frozenColumns: [],
                        columns: [monthOperEstColums],
                        //禁止行选中
                        onClickRow: function () {
                            $('#month_oper_est_time_dg').datagrid('clearSelections');
                        },
                        toolbar: [{
                            text: '上一月',
                            iconCls: 'icon-arrow_left',
                            handler: function () {
                                monthOperEstAdjustnum--;
                                monthOperEstDatagrid(monthOperEstAdjustnum); 
                            }
                        }, {
                            text: '下一月',
                            iconCls: 'icon-arrow_right',
                            handler: function () {
                                monthOperEstAdjustnum++;
                                monthOperEstDatagrid(monthOperEstAdjustnum);
                            }
                        }, {
                            text: '本月',
                            iconCls: 'icon-arrow_undo',
                            handler: function () {
                                monthOperEstAdjustnum=0;
                                monthOperEstDatagrid(monthOperEstAdjustnum);
                            }
                        }, {
                            text: '刷新',
                            iconCls: 'icon-arrow_refresh',
                            handler: function () {
                                monthOperEstDatagrid(monthOperEstAdjustnum,true);
                            }
                        }, '-', { text: '过滤已完成订单:' }, {
                            id: 'sbMonthOperEst'
                        }, '-',
                         {
                             text: '导出',
                             iconCls: 'icon-page_excel',
                             handler: function () { exportDgData("month_oper_est_time"); }
                         },
                        ],
                        onLoadSuccess: function (data) {
                            $('#sbMonthOperEst').switchbutton({
                                checked: monthOperRemoveFinished,
                                onText: '是',
                                offText: '否',
                                onChange: function (checked) {
                                    monthOperRemoveFinished = checked;
                                    monthOperEstDatagrid(monthOperEstAdjustnum);
                                }
 
                            });
                        }
                    });

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })
        }



        </script>

          <script>
              //公共事件处理

        $(function () {
            monthdatagrid(monthadjust);//月产能预警
            week_all_datagrid(week_all_adjust);//周产能预警
            monthoperdatagrid(monthOperAdjustnum);//月工序产能预警
            weekdatagrid(weekadjust);//周工序产能预警    
            monthOperEstDatagrid(monthOperEstAdjustnum);//启动预估
            $('.datagrid-cell').css('font-size', '18px'); //更改的是datagrid中的数据
            $('.datagrid-header .datagrid-cell span ').css('font-size', '19px'); //datagrid中的列名称
        })

        //改变部门选项时重新加载数据--改变排程方式时
        function ui_home_searchdata() {
             //月产能预警刷新
            $("#month_all_time_dg").datagrid('load', {
                key: 'datarows',
                cycle: "month",
                adjustNum: monthadjust,
                department: $('#Department').val(),//分部门
                classifyOper: false,
                schedule: $('#schedule').val(),//排程方式
                removefinished: monthremovefinished
            });
            //周产能预警刷新
            $("#week_all_time_dg").datagrid('load', {
                key: 'datarows',
                cycle: "week",
                adjustNum: week_all_adjust,
                removefinished: week_all_removefinished,
                classifyOper: false,
                schedule: $('#schedule').val(),//排程方式
                department: $('#Department').val()
            });
            //月工序产能预警
            $("#month_oper_time_dg").datagrid('load', {
                key: 'datarows',
                cycle: "month",
                adjustNum: monthOperAdjustnum,
                removefinished: monthOperRemoveFinished,
                classifyOper: true,
                schedule: $('#schedule').val(),//排程方式
                department: $('#Department').val() 
            });
            //周工序产能预警
            $("#week_oper_time_dg").datagrid('load', {
                key: 'datarows',
                cycle: "week",
                adjustNum: weekadjust,
                removefinished: weekremovefinished,
                classifyOper: true,
                schedule: $('#schedule').val(),//排程方式
                department: $('#Department').val()  
            }); 
        }

    </script>

</head>
<body class="easyui-layout">
    <div data-options="region:'north',border:false" style="height: 60px; background-color: #F5F5F5; padding: 10px; font-size: x-large;">
        <img src="~/Content/images/Logo.png" width="40" height="44" />双益机械信息化管理系统
        @*<img src="~/Content/images/Logo.png" width="40" height="44" />信息化管理系统*@
        <div style="position: absolute; right: 5px; top: 10px;">
            欢迎您：<span style="color: #0082ff; ">@ViewBag.RealName</span>  @ViewBag.TimeView   @ViewBag.DayDate
        </div>
        <div style="position: absolute; right: 0px; bottom: 0px; ">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-set1'" onclick="changePwd('');">
                修改密码
            </a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-stop'" onclick="loginOut();">
                退出系统
            </a>
        </div>
    </div>

    <div data-options="region:'west',split:true,title:'功能导航'" style="width: 180px; background-color: white;">
        <div id="RightAccordion" class="easyui-accordion">
        </div>
    </div>
    <div data-options="region:'center'">
        <div id="tabs" class="easyui-tabs" fit="true" border="false" data-options=" tools:[
                    {iconCls : 'icon-arrow_refresh',text:'刷新',handler:refreshTab},
                    {iconCls : 'icon-delete3',text:'关闭全部',handler:closeTab}
                    ]">
            <div id="home" title="系统门户" data-options="iconCls:'icon-house',closable:false" style="padding:10px">
                <div class="easyui-layout" data-options="fit:true">
                    <!-- 上部第一行布局，产能预警 -->
                    <div hidden="hidden"  data-options="region:'north',title:''" style="overflow:auto; height:25px ;border:1px,solid,blue; width:150px">
                        <select name="Department" id="Department" style="width:100px; height:25px" onchange="ui_home_searchdata();">
                            <option value="sw">钢水控流事业部</option>
                            <option value="ml">冶金工程事业部</option>
                            <option value="mf">制造部</option>
                            <option value="ec">电缆卷筒事业部</option>
                            <option value="sd">能源环境事业部</option>
                            <option value="all" selected="selected">全部</option>
                        </select>
                        <select name="schedule" id="schedule" style="width:100px; height:25px" onchange="ui_home_searchdata();">
                            <option value="plan" selected="selected">计划排程</option>
                            <option value="autocal">自动排程</option> 
                        </select>
                    </div>

                    <!-- 中间布局，display:inline;占位 -->
                    <div data-options="region:'center'">
                        <!--   <div style="height: 150px;float:left;margin-left: 5px;width: 600px;overflow:auto;"> </div>-->
                        <div class="easyui-panel" title="月产能预警" style="height:260px;width:auto;overflow:auto;" data-options="closable:true,href:''">
                            <table id="month_all_time_dg" data-options="fit:true,border:false"></table>
                        </div>
                        <!-- add 20190410-->
                        <div class="easyui-panel" title="周产能预警" style="height:260px;width:auto;overflow:auto;" data-options="closable:true,href:''">
                            <table id="week_all_time_dg" data-options="fit:true,border:false"></table>
                        </div>
                        <!-- add 20190125-->
                        <div class="easyui-panel" title="月工序产能预警" style="height:300px;width: auto;overflow:auto;" data-options="closable:true,href:''">
                            <table id="month_oper_time_dg" data-options="fit:true,border:false"></table>
                        </div>
                        <div class="easyui-panel" title="周工序产能预警" style="height:300px;width: auto;overflow:auto;" data-options="closable:true,href:''">
                            <table id="week_oper_time_dg" data-options="fit:true,border:false"></table>
                        </div>
                        <!-- add 20190715-->
                        <div class="easyui-panel" title="月工序产能(预估)预警" style="height:300px;width: auto;overflow:auto;" data-options="closable:true,href:''">
                            <table id="month_oper_est_time_dg" data-options="fit:true,border:false"></table>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</body>
</html>
